package cat.sun.dialogs;

import cat.sun.R;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TextView;

public class HelpDialog extends DialogFragment
{
	public static HelpDialog newInstance()
	{
		HelpDialog dialog = new HelpDialog();		
		return dialog;
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{		
		super.onCreate(savedInstanceState);
		setStyle(DialogFragment.STYLE_NO_FRAME, 0);	
		//setCancelable(false);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) 
	{
		View view = inflater.inflate(R.layout.dialog_help, container,false);		
		final Context context = getActivity();		
				
		TextView title = (TextView) view.findViewById(R.id.dialog_help_title);
		title.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf"));
				
		final ImageView close = (ImageView) view.findViewById(R.id.dialog_help_close);
		
		close.setOnClickListener(new View.OnClickListener() 
		{			
			@Override
			public void onClick(View v) 
			{
				dismiss();
			}			
		});

		final TextView tab1 = (TextView) view.findViewById(R.id.dialog_help_tab1);
		final TextView tab2 = (TextView) view.findViewById(R.id.dialog_help_tab2);
		final TextView text = (TextView) view.findViewById(R.id.dialog_help_text);
		
		tab1.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf"));
		tab2.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf"));
		text.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Regular.ttf"));
		
		final HorizontalScrollView scrollView = (HorizontalScrollView) view.findViewById(R.id.dialog_help_scroll_hor);		
					
		tab1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				tab1.setBackgroundResource(R.drawable.saper_tab_pressed);
				tab2.setBackgroundResource(R.drawable.saper_tab);
				text.setText(R.string.text_1);		
				scrollView.scrollTo(0, 0);
			}
		});
		
		tab2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				tab2.setBackgroundResource(R.drawable.saper_tab_pressed);
				tab1.setBackgroundResource(R.drawable.saper_tab);
				text.setText(R.string.text_2);		
				scrollView.scrollTo(scrollView.getRight(), 0);
			}
		});
		
		return view;
	}
		
}
